package com.cuijian.demo.config;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.cuijian.demo.common.JsonResult;

public class ExceptionInterceptor implements Interceptor {

    @Override
    public void intercept(Invocation inv) {
        try {
            inv.invoke();
        } catch (Exception e) {
            e.printStackTrace();
            inv.getController().renderJson(JsonResult.error("服务器内部错误: " + e.getMessage()).toMap());
        }
    }
}